<template>
  <div>
    <h1 class="title">物流平台</h1>
    <el-menu :router="true" background-color="#001529" text-color="#fff">
      <!-- 循环地设置列表 -->
      <menus-vue
        v-for="(item, index) in menuData"
        :menu="item"
        :key="index"
      ></menus-vue>
    </el-menu>
  </div>
</template>

<script>
import { get } from "@/utils/http";
import MenusVue from "./MenusVue.vue";
export default {
  data() {
    return {
      menuData: [],
    };
  },
  created() {
    this.getMenu();
  },
  methods: {
    async getMenu() {
      let { data } = await get("/menu"); // 发送get请求到menu路径下,并获取它内部的数据
      console.log(data);
      this.menuData = data; // 通过返回的数据设置左边的列表
    },
  },
  components: {
    MenusVue,
  },
};
</script>

<style lang="less" scoped>
.title {
  line-height: 50px;
  color: #fff;
  text-align: center;
  font-weight: 500;
}
</style>
